import 'dart:async';
import 'dart:io';

import 'package:app/Log/logger.dart';
import 'package:flutter/material.dart';
import 'package:flutter_kit_debug/log.dart';
import 'package:flutter_localizations/flutter_localizations.dart';


void main() {
  //其他类型异常
  Log.dealLevel = LogLevel.info;
  Log.D("launch");
  runZoned(
        () => realRunApp(),
    onError: (dynamic ex, StackTrace stack) {
      print("$ex  $stack");
    },
  );
}



void realRunApp() async {
  Log.I("realRunApp");
  final _prettyPrinter = PrettyPrinter(
    methodCount: 3, // number of method calls to be displayed
    //被调用的方法数量
    errorMethodCount: 8, // number of method calls if stacktrace is provided
    lineLength: 150,// width of the output
    colors: true,
    printEmojis: true,
    printTime: true,
  );

  final logger = Logger(
    printer: _prettyPrinter,
  );
  logger.i("realRunApp");

  WidgetsFlutterBinding.ensureInitialized();
  runApp(MyAppPage());
}

class MyAppPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState(){
    // TODO: implement getPageState
    return _MyAppPageState();
  }
}

class _MyAppPageState extends State<MyAppPage>{

  @override
  Widget build(BuildContext context) {
    Log.D("build");
    return MaterialApp(
        localizationsDelegates: [
          GlobalMaterialLocalizations.delegate,
          GlobalWidgetsLocalizations.delegate,
        ],
        supportedLocales: [
          const Locale('zh', 'CN'),
          const Locale('en', 'US'),
        ],
        title: "",
        theme: ThemeData(
          primarySwatch: Colors.blue,
          visualDensity: VisualDensity.adaptivePlatformDensity,
          buttonTheme: new ButtonThemeData(
              minWidth: 0,
              height: 0,
              padding: EdgeInsets.all(0),
              buttonColor: Colors.transparent),
        ),
        home: Container(color: Color(0xfff1f2f3),),
        routes: {});
  }
}

